// -59231
public class P27 {
	public static boolean isPrime(int n) {
		if (n < 2) {
			return false;
		}
		
		int m = (int) Math.sqrt(n);
		
		for (int i = 2; i <= m; i++) {
			if (n%i == 0) {
				return false;
			}
		}
		
		return true;
	}
	
	public static int cal(int a, int b) {
		int n = 0;
		while (isPrime(n * n + a * n + b)) {
		//	System.out.print(n * n + a * n + b + ",");
			n++;
		}
		
		
		return n;
	}
	
	public static void main(String[] args) {
		int max = 0;
		int a = 0;
		int b = 0;
		
		for (int i = -999; i < 1000; i++) {
			//System.out.println(i);
			for (int j = -999; j < 1000; j++) {
				int n = cal(i, j);
				
				if (i == 1 && j== 41) {
					System.out.println("1, 41:" + n);
				}
				if (max < n) {
					a = i;
					b = j;
					max = n;
					System.out.println("max:" + max + ",i:" + i + ",j:" + j);
				}
			}
		}
		
		System.out.println(a * b);
	}
}
